<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>胡鹏 - 个人中心 | 优选商城</title>
    <meta name="description" content="您的个人信息与购买记录中心">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
         :root {
            --primary: #4361ee;
            --secondary: #3f37c9;
            --accent: #ff6b6b;
            --success: #4cc9f0;
            --light: #f8f9fa;
            --dark: #2b2d42;
            --gray: #6c757d;
            --light-gray: #e9ecef;
            --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
            --transition: all 0.3s ease;
        }
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
        }
        
        body {
            background: linear-gradient(135deg, #f5f7fa 0%, #eef2f7 100%);
            color: var(--dark);
            line-height: 1.6;
            min-height: 100vh;
            padding: 20px;
        }
        
        .container {
            max-width: 1200px;
            margin: 0 auto;
            position: relative;
        }
        /* 返回按钮样式 */
        
        .back-btn {
            position: absolute;
            top: 20px;
            right: 20px;
            z-index: 100;
            background: rgba(255, 255, 255, 0.9);
            border: none;
            border-radius: 30px;
            padding: 10px 20px;
            display: flex;
            align-items: center;
            gap: 8px;
            font-weight: 600;
            color: var(--primary);
            cursor: pointer;
            transition: var(--transition);
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
            backdrop-filter: blur(5px);
        }
        
        .back-btn:hover {
            background: white;
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
        }
        
        .back-btn i {
            transition: transform 0.3s ease;
        }
        
        .back-btn:hover i {
            transform: translateX(-3px);
        }
        /* 头部样式 */
        
        header {
            background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
            color: white;
            padding: 25px 30px;
            border-radius: 16px;
            margin-bottom: 30px;
            box-shadow: var(--card-shadow);
            position: relative;
            overflow: hidden;
        }
        
        header::before {
            content: "";
            position: absolute;
            top: -50%;
            left: -50%;
            width: 200%;
            height: 200%;
            background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 70%);
            transform: rotate(30deg);
        }
        
        .user-header {
            display: flex;
            align-items: center;
            gap: 25px;
            position: relative;
            z-index: 2;
        }
        
        .avatar-container {
            position: relative;
        }
        
        .avatar {
            width: 110px;
            height: 110px;
            border-radius: 50%;
            object-fit: cover;
            border: 4px solid rgba(255, 255, 255, 0.3);
            background: linear-gradient(45deg, #4cc9f0, #4361ee);
            display: flex;
            align-items: center;
            justify-content: center;
            color: white;
            font-size: 2.5rem;
            font-weight: bold;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
        }
        
        .online-status {
            position: absolute;
            bottom: 8px;
            right: 8px;
            width: 20px;
            height: 20px;
            background-color: #4ade80;
            border: 2px solid white;
            border-radius: 50%;
            box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
        }
        
        .user-info h1 {
            font-size: 2.2rem;
            margin-bottom: 8px;
            text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
        }
        
        .user-meta {
            display: flex;
            gap: 15px;
            margin-bottom: 15px;
            flex-wrap: wrap;
        }
        
        .user-tag {
            background: rgba(255, 255, 255, 0.2);
            padding: 8px 15px;
            border-radius: 30px;
            font-size: 0.9rem;
            display: flex;
            align-items: center;
            gap: 8px;
            transition: var(--transition);
        }
        
        .user-tag:hover {
            background: rgba(255, 255, 255, 0.3);
            transform: translateY(-2px);
        }
        
        .user-stats {
            display: flex;
            gap: 35px;
            margin-top: 15px;
            flex-wrap: wrap;
        }
        
        .stat-item {
            text-align: center;
            min-width: 80px;
            padding: 10px;
            background: rgba(255, 255, 255, 0.15);
            border-radius: 12px;
            transition: var(--transition);
        }
        
        .stat-item:hover {
            background: rgba(255, 255, 255, 0.25);
            transform: translateY(-3px);
        }
        
        .stat-value {
            font-size: 1.8rem;
            font-weight: bold;
            margin-bottom: 3px;
        }
        
        .stat-label {
            font-size: 0.95rem;
            opacity: 0.9;
        }
        /* 主要内容区域 */
        
        .content {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 30px;
            margin-bottom: 40px;
        }
        
        @media (max-width: 900px) {
            .content {
                grid-template-columns: 1fr;
            }
        }
        
        .card {
            background: white;
            border-radius: 16px;
            padding: 30px;
            box-shadow: var(--card-shadow);
            transition: var(--transition);
            height: 100%;
            display: flex;
            flex-direction: column;
            border: 1px solid rgba(0, 0, 0, 0.05);
        }
        
        .card:hover {
            transform: translateY(-8px);
            box-shadow: 0 15px 40px rgba(67, 97, 238, 0.15);
        }
        
        .card-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 25px;
            padding-bottom: 15px;
            border-bottom: 2px solid var(--light-gray);
        }
        
        .card h2 {
            color: var(--dark);
            font-size: 1.6rem;
            display: flex;
            align-items: center;
            gap: 10px;
        }
        
        .card h2 i {
            color: var(--primary);
        }
        
        .activity-list {
            list-style: none;
        }
        
        .activity-item {
            display: flex;
            gap: 18px;
            padding: 18px 15px;
            border-radius: 12px;
            transition: var(--transition);
            margin-bottom: 10px;
        }
        
        .activity-item:hover {
            background-color: rgba(67, 97, 238, 0.05);
            box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
        }
        
        .activity-icon {
            width: 46px;
            height: 46px;
            background: var(--light);
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--primary);
            flex-shrink: 0;
            font-size: 1.2rem;
            border: 1px solid var(--light-gray);
            box-shadow: 0 3px 8px rgba(0, 0, 0, 0.05);
        }
        
        .activity-content {
            flex-grow: 1;
        }
        
        .activity-title {
            font-weight: 600;
            margin-bottom: 8px;
            font-size: 1.1rem;
            color: var(--dark);
        }
        
        .activity-desc {
            color: var(--gray);
            margin-bottom: 8px;
            font-size: 0.95rem;
        }
        
        .activity-time {
            color: var(--gray);
            font-size: 0.85rem;
            display: flex;
            align-items: center;
            gap: 5px;
        }
        
        .chart-container {
            position: relative;
            height: 280px;
            margin-top: 15px;
            flex-grow: 1;
        }
        
        .data-controls {
            display: flex;
            justify-content: space-between;
            margin-top: 25px;
            gap: 15px;
        }
        
        .btn {
            padding: 12px 25px;
            border: none;
            border-radius: 10px;
            cursor: pointer;
            font-weight: 600;
            transition: var(--transition);
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 1rem;
        }
        
        .btn-primary {
            background: var(--primary);
            color: white;
            box-shadow: 0 4px 15px rgba(67, 97, 238, 0.3);
        }
        
        .btn-primary:hover {
            background: var(--secondary);
            transform: translateY(-3px);
            box-shadow: 0 6px 20px rgba(67, 97, 238, 0.4);
        }
        
        .btn-secondary {
            background: var(--light);
            color: var(--dark);
            border: 1px solid var(--light-gray);
        }
        
        .btn-secondary:hover {
            background: #f0f2f5;
            transform: translateY(-2px);
        }
        /* 页脚样式 */
        
        footer {
            text-align: center;
            margin-top: 40px;
            color: var(--gray);
            font-size: 0.95rem;
            padding: 20px;
            border-top: 1px solid var(--light-gray);
        }
        /* 徽章样式 */
        
        .badge {
            display: inline-block;
            padding: 4px 10px;
            border-radius: 20px;
            font-size: 0.8rem;
            font-weight: 600;
            margin-left: 8px;
        }
        
        .badge-primary {
            background: var(--primary);
            color: white;
        }
        
        .badge-success {
            background: #4ade80;
            color: white;
        }
        /* 加载动画 */
        
        .spinner {
            width: 40px;
            height: 40px;
            border: 4px solid rgba(67, 97, 238, 0.2);
            border-top: 4px solid var(--primary);
            border-radius: 50%;
            animation: spin 1s linear infinite;
            margin: 20px auto;
        }
        
        @keyframes spin {
            0% {
                transform: rotate(0deg);
            }
            100% {
                transform: rotate(360deg);
            }
        }
        /* 进度条 */
        
        .progress-container {
            width: 100%;
            background-color: #f0f0f0;
            border-radius: 10px;
            margin: 10px 0;
            overflow: hidden;
        }
        
        .progress-bar {
            height: 10px;
            background: linear-gradient(90deg, var(--primary), var(--accent));
            border-radius: 10px;
            transition: width 0.5s ease;
        }
        /* 响应式调整 */
        
        @media (max-width: 768px) {
            .user-header {
                flex-direction: column;
                text-align: center;
            }
            .user-meta,
            .user-stats {
                justify-content: center;
            }
            .avatar {
                margin: 0 auto 15px;
            }
            .back-btn {
                position: relative;
                top: 0;
                right: 0;
                margin: 0 auto 20px;
                width: fit-content;
            }
        }
    </style>
</head>

<body>
    <div class="container">
        <!-- 返回按钮 -->
        <button class="back-btn" onclick="returnToHome()">
            <i class="fas fa-arrow-left"></i> 返回主页
        </button>

        <!-- 用户头部信息区域 -->
        <header>
            <div class="user-header">
                <div class="avatar-container">
                    <div class="avatar">胡</div>
                    <div class="online-status"></div>
                </div>
                <div class="user-info">
                    <h1>胡鹏 <span class="badge badge-primary">钻石会员</span></h1>
                    <div class="user-meta">
                        <div class="user-tag">
                            <i class="fas fa-map-marker-alt"></i> 金华市
                        </div>
                        <div class="user-tag">
                            <i class="fas fa-envelope"></i> hupeng@example.com
                        </div>
                        <div class="user-tag">
                            <i class="fas fa-phone-alt"></i> 138****5678
                        </div>
                    </div>
                    <div class="user-stats">
                        <div class="stat-item">
                            <div class="stat-value">¥8,560</div>
                            <div class="stat-label">本月消费</div>
                        </div>
                        <div class="stat-item">
                            <div class="stat-value">124</div>
                            <div class="stat-label">累计订单</div>
                        </div>
                        <div class="stat-item">
                            <div class="stat-value">89%</div>
                            <div class="stat-label">好评率</div>
                        </div>
                        <div class="stat-item">
                            <div class="stat-value">12</div>
                            <div class="stat-label">优惠券</div>
                        </div>
                    </div>
                </div>
            </div>
        </header>

        <!-- 主要内容区域 -->
        <div class="content">
            <!-- 左侧：个人动态 -->
            <div class="card">
                <div class="card-header">
                    <h2><i class="fas fa-history"></i> 最近活动</h2>
                    <button class="btn btn-secondary" onclick="viewAllActivities()">

                        <i class="fas fa-list"></i> 查看全部
                        
                        </button>
                </div>
                <ul class="activity-list">
                    <li class="activity-item">
                        <div class="activity-icon">
                            <i class="fas fa-shopping-cart"></i>
                        </div>
                        <div class="activity-content">
                            <div class="activity-title">成功购买商品 <span class="badge badge-success">已完成</span></div>
                            <div class="activity-desc">智能手表 Series 5 - 黑色款 × 1</div>
                            <div class="activity-time">
                                <i class="far fa-clock"></i> 10分钟前 | 金额: ¥1,299
                            </div>
                        </div>
                    </li>
                    <li class="activity-item">
                        <div class="activity-icon">
                            <i class="fas fa-comment-dots"></i>
                        </div>
                        <div class="activity-content">
                            <div class="activity-title">商品评价 <span class="badge badge-primary">已发布</span></div>
                            <div class="activity-desc">"无线蓝牙耳机音质非常出色，续航能力强"</div>
                            <div class="activity-time">
                                <i class="far fa-clock"></i> 2小时前
                            </div>
                        </div>
                    </li>
                    <li class="activity-item">
                        <div class="activity-icon">
                            <i class="fas fa-gift"></i>
                        </div>
                        <div class="activity-content">
                            <div class="activity-title">领取优惠券 <span class="badge badge-primary">已使用</span></div>
                            <div class="activity-desc">满¥1000减¥150 限时优惠券</div>
                            <div class="activity-time">
                                <i class="far fa-clock"></i> 昨天
                            </div>
                        </div>
                    </li>
                    <li class="activity-item">
                        <div class="activity-icon">
                            <i class="fas fa-truck"></i>
                        </div>
                        <div class="activity-content">
                            <div class="activity-title">物流更新 <span class="badge badge-primary">运输中</span></div>
                            <div class="activity-desc">订单 #20240521007 已到达金华转运中心</div>
                            <div class="activity-time">
                                <i class="far fa-clock"></i> 2025-06-15
                            </div>
                        </div>
                    </li>
                </ul>
            </div>

            <!-- 右侧：购买记录 -->
            <div class="card">
                <div class="card-header">
                    <h2><i class="fas fa-chart-line"></i> 购买记录分析</h2>
                    <div class="user-tag">
                        <i class="fas fa-sync-alt"></i> 实时更新
                    </div>
                </div>

                <div class="progress-container">
                    <div class="progress-bar" style="width: 75%;"></div>
                </div>
                <p>本月消费进度: 75% (¥8,560 / ¥11,420)</p>

                <div class="chart-container">
                    <canvas id="purchaseChart"></canvas>
                </div>

                <div class="data-controls">
                    <button class="btn btn-secondary" id="exportData">
                        <i class="fas fa-file-export"></i> 导出数据
                    </button>
                    <button class="btn btn-primary" id="refreshChart">
                        <i class="fas fa-sync"></i> 刷新图表
                    </button>
                </div>
            </div>
        </div>

        <footer>
            <p>© 2025 优选商城 | 个人中心 | 最后更新: 2025-06-16</p>
            <p>服务热线: 400-888-8888 | 客服邮箱: service@youxuanshop.com</p>
        </footer>
    </div>

    <!-- 引入Chart.js -->
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>

    <script>
        // 返回主页函数
        function returnToHome() {
            // 这里可以改为您的主页URL
            window.location.href = "index.html";
        }

        function viewAllActivities() {

            window.location.href = "index31.html";

        }

        // 页面加载完成后执行
        document.addEventListener('DOMContentLoaded', function() {
            // 初始化图表
            initChart();

            // 设置刷新按钮事件
            document.getElementById('refreshChart').addEventListener('click', function() {
                updateChart();
            });

            // 设置导出数据按钮事件
            document.getElementById('exportData').addEventListener('click', function() {
                exportUserData();
            });

            // 每秒刷新一次图表
            setInterval(updateChart, 5000);
        });

        // 图表变量
        let purchaseChart;

        // 初始化图表
        function initChart() {
            const ctx = document.getElementById('purchaseChart').getContext('2d');

            // 渐变背景
            const gradient = ctx.createLinearGradient(0, 0, 0, 400);
            gradient.addColorStop(0, 'rgba(67, 97, 238, 0.4)');
            gradient.addColorStop(1, 'rgba(67, 97, 238, 0.05)');

            // 创建柱状图
            purchaseChart = new Chart(ctx, {
                type: 'bar',
                data: {
                    labels: ['电子产品', '服装鞋帽', '家居用品', '美妆护肤', '食品生鲜', '图书文具'],
                    datasets: [{
                        label: '消费金额 (¥)',
                        data: [3560, 1890, 1250, 980, 650, 230],
                        backgroundColor: gradient,
                        borderColor: '#4361ee',
                        borderWidth: 1,
                        borderRadius: 8,
                        borderSkipped: false,
                    }]
                },
                options: {
                    responsive: true,
                    maintainAspectRatio: false,
                    plugins: {
                        legend: {
                            display: false
                        },
                        tooltip: {
                            backgroundColor: 'rgba(43, 45, 66, 0.9)',
                            padding: 12,
                            cornerRadius: 6,
                            displayColors: false,
                            callbacks: {
                                title: function() {
                                    return '';
                                },
                                label: function(context) {
                                    return `消费金额: ¥${context.parsed.y}`;
                                }
                            }
                        }
                    },
                    scales: {
                        y: {
                            beginAtZero: true,
                            grid: {
                                color: 'rgba(0, 0, 0, 0.05)'
                            },
                            ticks: {
                                callback: function(value) {
                                    return '¥' + value;
                                }
                            }
                        },
                        x: {
                            grid: {
                                display: false
                            }
                        }
                    },
                    animation: {
                        duration: 1000,
                        easing: 'easeOutQuart'
                    }
                }
            });
        }

        // 更新图表数据
        function updateChart() {
            // 生成新的随机数据
            const newData = purchaseChart.data.datasets[0].data.map(value => {
                // 在原有基础上随机增加
                const change = Math.floor(Math.random() * 100) + 50;
                return value + change;
            });

            // 更新图表数据
            purchaseChart.data.datasets[0].data = newData;
            purchaseChart.update();
        }

        // 导出用户数据
        function exportUserData() {
            // 创建要导出的数据对象
            const userData = {
                name: '胡鹏',
                level: '钻石会员',
                location: '金华市',
                email: 'hupeng@example.com',
                purchaseData: purchaseChart.data.datasets[0].data,
                categories: purchaseChart.data.labels
            };

            // 保存到localStorage
            localStorage.setItem('userPurchaseData', JSON.stringify(userData));

            // 模拟导出文件
            const dataStr = JSON.stringify(userData, null, 2);
            const blob = new Blob([dataStr], {
                type: 'application/json'
            });
            const url = URL.createObjectURL(blob);

            // 创建下载链接
            const a = document.createElement('a');
            a.href = url;
            a.download = 'user_purchase_data.json';
            document.body.appendChild(a);
            a.click();

            // 清理
            setTimeout(() => {
                document.body.removeChild(a);
                URL.revokeObjectURL(url);
            }, 100);

            // 显示提示
            alert('购买数据已导出为JSON文件!');
        }
    </script>
</body>

</html>